package org.springframework.sandbox.base;

public class BaseResult {
	private String errorCode;
	private String errorMsg;
	private Object data;


	public BaseResult() {
	}

	public BaseResult(String retCode, String retMsg, Object data) {
		this.data = data;
		this.errorCode = retCode;
		this.errorMsg = retMsg;
	}
	
	public static BaseResult success() {
		BaseResult serviceResult = new BaseResult(ErrorCode.SuccessRetCode, ErrorCode.SuccessRetInfo, null);
		return serviceResult;
	}

	public static BaseResult success(Object obj) {
		BaseResult serviceResult = new BaseResult(ErrorCode.SuccessRetCode, ErrorCode.SuccessRetInfo, obj);
		return serviceResult;
	}

	public static BaseResult fail(String code, String info) {
		BaseResult serviceResult = new BaseResult(code, info, null);
		return serviceResult;
	}

	public static BaseResult fail(String code, String info, Object object) {
		BaseResult serviceResult = new BaseResult(code, info, object);
		return serviceResult;
	}

	public static BaseResult fail(String info) {
		BaseResult serviceResult = new BaseResult(ErrorCode.BussnissErrorRetCode,  info, null);
		return serviceResult;
	}
	
	public static BaseResult exception(String info) {
		BaseResult serviceResult = new BaseResult(ErrorCode.ExceptionRetCode, ErrorCode.ExceptionRetInfo , info);
		return serviceResult;
	}
	
	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public String getErrorMsg() {
		return errorMsg;
	}

	public void setErrorMsg(String errorMsg) {
		this.errorMsg = errorMsg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}
	
	
}
